import { ref } from "vue";
import { FormItemComponentType, FormItemData } from "/@/components/CURDDialog/models";
import { RoleItem, RoleType } from "/@/api/aiot/role/models";
import { useI18n } from "/@/locales/useI18n";
import { PatternKey } from "/@/utils/verify";
import { enumToOptions } from "/@/utils/common";

export function useRoleModel() {
  const { t } = useI18n();
  const roleModel = ref<RoleItem>({
    roleName: "",
    roleDescription: "",
    // roleType: RoleType.other,
  });
  const roleModelFormSetting: FormItemData<RoleItem>[] = [
    {
      key: "roleName",
      label: t("aiot.role.name"),
      pattern: PatternKey.nameWithoutNum,
      required: true,
      max: 32,
    },
    {
      key: "roleDescription",
      label: t("aiot.role.des"),
      type: FormItemComponentType.TEXTAREA,
      max: 255,
    },
    // {
    //   key: "roleType",
    //   label: t("aiot.role.type"),
    //   type: FormItemComponentType.SELECT,
    //   props: {
    //     options: enumToOptions(RoleType, "roleType"),
    //   },
    // },
  ];
  return {
    roleModel,
    roleModelFormSetting,
  };
}
